using System;
using System.Diagnostics;
using System.Windows;

namespace ThreadingPrimeNumberSample
{
    /// <summary>
    /// Disposable was implmented so that it could be confirmed that
    /// the code doesn't cause memory leaks. To confirm that there are
    /// no leaks run the program in release and click the GC Collect button
    /// after closing a window and watch the debug output window for messages.
    /// </summary>
    public class LeakDebugger : IDisposable
    {
        #region IDisposable

        public void Dispose()
        {
            Dispose(true);
        }

        ~LeakDebugger()
        {
            Dispose(false);
        }

        protected virtual void Dispose(bool isDisposing)
        {
            MessageBox.Show(isDisposing
                                ? "Disposed " + ToString()
                                : "Finalized " + ToString());

            //Debug.WriteLine(isDisposing
            //                    ? "Disposed " + ToString()
            //                    : "Finalized " + ToString());
        }

        #endregion IDisposable
    }
}